Skip to main content

All Questions

4votes
3answers
1kviews

Coding exercise to represent an integer as words using python

Context: Convert a non-negative integer num to its English words representation. Example 1: Input: num = 123 Output: "One Hundred Twenty Three" Example 2: Input: num = 12345 Output: "...
Silah's user avatar
4votes
1answer
88views

Centre of mass based TSP solution (2)

I updated the code to a working state. My previous question. Even if this code working I wonder if I can write this code in a more efficient way. Maybe less for loops Etc. ...
tumr's user avatar
4votes
4answers
1kviews

Creating an O(n) algorithm for an array of integers

To avoid plagiarism in my university, I am going to modify the problem. Henry likes to jump from building to building. The heights of each building are given as a list of H numbers. We also number ...
Lesserrafim's user avatar
5votes
1answer
123views

Sorting songs with the ability to save and resume partial sorts

I listen to a lot of music (~4k h/y) and managing thousands of songs is a bit of a challenging. To improve my listening experience I want to better organize my collection. One thing I want to do is ...
Peilonrayz's user avatar
3votes
1answer
363views

Python function to find the count of digits of numerals in base n up to a given limit

This is a simple exercise to find the count of digits of all numerals in a given base up to a given limit (not including the limit), I wrote it to determine the ratio of bytes saved when the numbers ...
Ξένη Γήινος's user avatar
1vote
2answers
320views

Python script that makes generalized Ulam spirals

This is a Python script I wrote to generate generalized Ulam spirals. I call the spirals generated by my code Ulamish spirals, they are one dimensional polylines that cross all two dimensional lattice ...
Ξένη Γήινος's user avatar
6votes
3answers
821views

Python script to split overlapping ranges, version 4

This is the fourth iteration of a Python script I wrote that splits overlapping ranges, and this is the fastest version I have wrote so far, and also a version that works for all inputs. I have done ...
Ξένη Γήινος's user avatar
1vote
2answers
364views

Find the shortest distance between two letters

I've been tasked with finding the distance between two letters in the alphabet. Below is my solution. My main concerns are if there is any shorter way to do this, and if there are any edge cases I'm ...
Ben A's user avatar
  • 10.7k
2votes
0answers
135views

Snake game with constant time complexity algorithm

https://github.com/speedrun-program/constant_time_snake_game Memory efficient snake game with O(1) algorithm for snake movement and bug placement. Three grids are used: a grid representing the game ...
my_stack_exchange_account's user avatar
3votes
1answer
1kviews

Calculate overlap of two datetime objects

I would like to find out how much time lays in between 22.00 and 6.00 o’clock for a given event per day. So if the event start at 21.00 and ends at 23.59 the result would be 1.59. For a start at 22.00 ...
kiaora's user avatar
6votes
2answers
314views

A selection sort implemented in Python

I'm not proficient at Python. My question is twofold: whether this selection sort algorithm implementation for number lists could be considered clean code (in the sense of being modular and ...
Piovezan's user avatar
1vote
0answers
29views

Optimizing search algorithm for guessing list of strings via function returning bool if substring is in list [duplicate]

I trying to figure out the most effective way to accomplish this task: A function, check(), contains a list of strings. Calling the function with a string as ...
user avatar
2votes
3answers
404views

Most effective search algorithm for guessing list of strings via function returning bool if substring is in list using Python

I trying to figure out the most effective way to accomplish this task: A function, check(), contains a list of strings. Calling the function with a string as ...
n0k's user avatar
  • 21
6votes
1answer
198views

ASCII art smoke wisp generator

I've written a Python function that generates a smoke wisp/genie-tail shape using all 26 (and only 26) letters of the alphabet. Here are some examples of the kind of ASCII art I'm trying to produce: ...
user avatar
1vote
2answers
718views

Find the cheapest flight to reach from source to destination

As the input you get the flight schedule as an array, each element of which is the price of a direct flight between 2 cities ...
meallhour's user avatar

153050per page
close